import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import legacy from '@vitejs/plugin-legacy'

// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
  const server_url = mode === 'development' ? 'http://127.0.0.1:8000' : 'http://127.0.0.1:1280'
  return {
    build: {
      chunkSizeWarningLimit: 1500,
    },
    plugins: [
      vue(),
      legacy({
        targets: ['defaults', 'not IE 11']
      })
    ],
    server: {
      proxy: {
        '/api': {
          target: server_url,
          changeOrigin: true,
          rewrite: (path) => path.replace(/^\/api/, '')
        }
      }
    }
  }
})
